Skip to content

Made the C repo header only, and solved all warnings#1

Open
manuel-ai-commits wants to merge 1 commit intowinobes:masterfrom
manuel-ai-commits:rm_wrngs_header_only
Open

Made the C repo header only, and solved all warnings#1
manuel-ai-commits wants to merge 1 commit intowinobes:masterfrom
manuel-ai-commits:rm_wrngs_header_only

Conversation

@manuel-ai-commits
Copy link

Hello,
These are the improvements made:

  1. In my opinion using both .c and .h is not necessary for such a simple library, I have updated to a header only library.
  2. ./examples/*.c were not working, fixed it
  3. renamed the print_buffer into print_csv
  4. included the print_csv to the general header-only library
  5. solved all warnings that used to appear.
    Using the same command cc -Wall -W -Wextra -O2 src/example.c

Before:

In file included from src/example.c:5:
./csv.h:79:6: warning: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent definition [-Wdeprecated-non-prototype]
   79 | void csv_destroy_buffer();
      |      ^
./csv.c:287:6: note: conflicting prototype is here
  287 | void csv_destroy_buffer(CSV_BUFFER *buffer)
      |      ^
./csv.c:292:23: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  292 |         for (i = 0; i < buffer->rows; i++) {
      |                     ~ ^ ~~~~~~~~~~~~
./csv.c:293:31: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  293 |                 for (j = 0; j < buffer->width[i]; j++) {
      |                             ~ ^ ~~~~~~~~~~~~~~~~
./csv.c:363:22: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  363 |         for(i = 0; i < buffer->rows; i++) {
      |                    ~ ^ ~~~~~~~~~~~~
./csv.c:364:30: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  364 |                 for(j = 0; j < buffer->width[i]; j++) {
      |                            ~ ^ ~~~~~~~~~~~~~~~~
./csv.c:375:46: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  375 |                                 for(k = 0; k < buffer->field[i][j]->length - 1; k++) {
      |                                            ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./csv.c:388:30: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  388 |                         if(j < buffer->width[i] - 1)
      |                            ~ ^ ~~~~~~~~~~~~~~~~~~~~
./csv.c:390:36: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  390 |                         else if (i < buffer->rows - 1)
      |                                  ~ ^ ~~~~~~~~~~~~~~~~
./csv.c:409:31: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  409 |                 for (i = 0; i < dest_len; i++)
      |                             ~ ^ ~~~~~~~~
./csv.c:480:31: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  480 |                 for (i = 1; i < buffer->width[row]; i++) {
      |                             ~ ^ ~~~~~~~~~~~~~~~~~~
./csv.c:498:24: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  498 |         if (source_row > source->rows - 1) {
      |             ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
./csv.c:503:27: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
  503 |         while (dest->rows < (dest_row + 1)) 
      |                ~~~~~~~~~~ ^  ~~~~~~~~~~~~
./csv.c:516:22: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  516 |         for(i = 0; i < dest->width[dest_row]; i++)
      |                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~
./csv.c:529:25: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  529 |         for (i = row; i < buffer->rows-1; i++) 
      |                       ~ ^ ~~~~~~~~~~~~~~
./csv.c:543:27: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  543 |         for (i = entry; i < buffer->width[row]-1; i++)
      |                         ~ ^ ~~~~~~~~~~~~~~~~~~~~
./csv.c:612:52: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
  612 |                 for (i = buffer->width[row] - 1; i > entry; i--)
      |                                                  ~ ^ ~~~~~
16 warnings generated.

After: No warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant